using System.Collections.Generic;
using NDomain.Reflection;

namespace NDomain.Reflection
{
    public class ValueObjectProcessor : BaseClassProcessor
    {
        public override void Process(IClassInfoProvider clazz, IDomainInfo domainInfo)
        {
            IDictionary<string, IAttributeInfoProvider> attributes = AttributesAsDictionary(clazz.GetAttributes());

            if (!attributes.ContainsKey(typeof (ValueObjectAttribute).FullName)) return;

            if (attributes.ContainsKey(typeof (AggregateItemAttribute).FullName))
                domainInfo.NewValueObject(clazz.GetNamespace(), clazz.GetName(),
                                          (string)
                                          attributes[typeof (AggregateItemAttribute).FullName].GetPropertyValue("Name"));

            else
                domainInfo.NewValueObject(clazz.GetNamespace(), clazz.GetName());
        }
    }
}